const express = require('express')
const router = express.Router()
const db = require('../db/index')

//搜索电影
router.get('/search', (req, res) => {
    const sql = `select * from movieinfo where name like '%${req.query.name}%'`
    db.query(sql, (err, results) => {
        if (err) return res.cc(err)
        if (results.length === 0) {
            res.cc('未查询到该电影')
        } else {
            res.send({
                status: 200,
                message: '获取电影信息成功',
                data: results
            })
        }
    })
})

module.exports = router